package com.bos.service.impl;

import com.bos.data.model.BosCommentModel;
import com.bos.data.model.BosUserModel;
import com.bos.mapper.CommentMapper;
import com.bos.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("commentServiceImpl")
public class CommentServiceImpl implements CommentService {
    @Autowired
    CommentMapper commentMapper;

    //1.查询出评论表中的数据
    @Override
    public List<BosCommentModel> findComment(int id) {
        return commentMapper.findComment(id);
    }

    //2.将评论内容插入到评论表中
    @Transactional
    @Override
    public int insertComment(BosCommentModel comm) {
        return commentMapper.insertComment(comm);
    }

    //3.应该查询用户表中跟关联id对应的用户信息（评论人）
    @Override
    public BosUserModel findUserByID(int id) {
        return commentMapper.findUserByID(id);
    }

}
